package com.hotel.management.dto;



import javax.validation.constraints.Min;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;

/**
 * 员工查询条件数据传输对象
 * 用于封装员工查询的各种条件
 * 
 * @author Hotel Management Team
 * @version 1.0.0
 * @since 2024-06-28
 */
public class EmployeeQueryDTO implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 员工姓名（模糊查询）
     */
    @Size(max = 50, message = "员工姓名长度不能超过50个字符")
    private String name;

    /**
     * 性别 (男/女)
     */
    @Pattern(regexp = "^(男|女)$", message = "性别只能是'男'或'女'")
    private String gender;

    /**
     * 最小年龄
     */
    @Min(value = 18, message = "最小年龄不能小于18岁")
    private Integer minAge;

    /**
     * 最大年龄
     */
    @Min(value = 18, message = "最大年龄不能小于18岁")
    private Integer maxAge;

    /**
     * 职位
     */
    @Size(max = 30, message = "职位名称长度不能超过30个字符")
    private String position;

    /**
     * 角色ID
     */
    private Long roleId;

    /**
     * 员工状态 (在职/离职/休假)
     */
    @Pattern(regexp = "^(在职|离职|休假)$", message = "员工状态只能是'在职'、'离职'或'休假'")
    private String status;

    /**
     * 页码（从1开始）
     */
    @Min(value = 1, message = "页码必须大于0")
    private Integer pageNum = 1;

    /**
     * 每页大小
     */
    @Min(value = 1, message = "每页大小必须大于0")
    private Integer pageSize = 10;

    /**
     * 排序字段
     */
    private String sortBy = "createTime";

    /**
     * 排序方向 (ASC/DESC)
     */
    @Pattern(regexp = "^(ASC|DESC)$", message = "排序方向只能是'ASC'或'DESC'")
    private String sortDirection = "DESC";

    /**
     * 默认构造函数
     */
    public EmployeeQueryDTO() {
    }

    /**
     * 带参数的构造函数
     */
    public EmployeeQueryDTO(String name, String position, String status) {
        this.name = name;
        this.position = position;
        this.status = status;
    }

    /**
     * 获取偏移量（用于数据库查询）
     */
    public int getOffset() {
        return (pageNum - 1) * pageSize;
    }

    /**
     * 获取限制数量（用于数据库查询）
     */
    public int getLimit() {
        return pageSize;
    }

    // Getter and Setter methods
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Integer getPageNum() {
        return pageNum;
    }

    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public String getSortBy() {
        return sortBy;
    }

    public void setSortBy(String sortBy) {
        this.sortBy = sortBy;
    }

    public String getSortDirection() {
        return sortDirection;
    }

    public void setSortDirection(String sortDirection) {
        this.sortDirection = sortDirection;
    }
}
